
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 10/28/2012 23:51:28
-- Generated from EDMX file: C:\Projectos\JotaProjects\trunk\Organizador\MyOrganizerModel\Database\OrganizerModel.edmx
-- --------------------------------------------------



-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Books]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Books];
GO
IF OBJECT_ID(N'[dbo].[Calendar]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Calendar];
GO
IF OBJECT_ID(N'[dbo].[Movies]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Movies];
GO
IF OBJECT_ID(N'[dbo].[Reports]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Reports];
GO
IF OBJECT_ID(N'[dbo].[TvShows]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TvShows];
GO
IF OBJECT_ID(N'[dbo].[Users]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Users];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Books'
CREATE TABLE [dbo].[Books] (
    [BookId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [Name] varchar(50)  NULL,
    [Type] varchar(50)  NULL,
    [Completed] bit  NULL
);
GO

-- Creating table 'Calendar'
CREATE TABLE [dbo].[Calendar] (
    [CalendarId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [Date] datetime  NULL,
    [Color] varchar(50)  NULL,
    [Msg] varchar(max)  NULL
);
GO

-- Creating table 'Movies'
CREATE TABLE [dbo].[Movies] (
    [MovieId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [Name] varchar(50)  NULL,
    [Type] varchar(50)  NULL,
    [ViewedDate] varchar(50)  NULL,
    [Score] varchar(5)  NULL
);
GO

-- Creating table 'Reports'
CREATE TABLE [dbo].[Reports] (
    [ReportId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [ReportType] varchar(50)  NULL,
    [Message] varchar(max)  NULL,
    [CreatedDate] datetime  NULL,
    [State] varchar(50)  NULL
);
GO

-- Creating table 'TvShows'
CREATE TABLE [dbo].[TvShows] (
    [TvShowId] int IDENTITY(1,1) NOT NULL,
    [UserId] int  NULL,
    [Name] nchar(10)  NULL,
    [EpisodeNumber] int  NULL,
    [SeasonNumber] int  NULL,
    [LastViewedEpisode] int  NULL,
    [ReleaseDay] varchar(20)  NULL,
    [Score] varchar(5)  NULL
);
GO

-- Creating table 'Users'
CREATE TABLE [dbo].[Users] (
    [UserId] int IDENTITY(1,1) NOT NULL,
    [Name] varchar(50)  NULL,
    [Password] varchar(50)  NULL,
    [Email] varchar(100)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [BookId] in table 'Books'
ALTER TABLE [dbo].[Books]
ADD CONSTRAINT [PK_Books]
    PRIMARY KEY CLUSTERED ([BookId] ASC);
GO

-- Creating primary key on [CalendarId] in table 'Calendar'
ALTER TABLE [dbo].[Calendar]
ADD CONSTRAINT [PK_Calendar]
    PRIMARY KEY CLUSTERED ([CalendarId] ASC);
GO

-- Creating primary key on [MovieId] in table 'Movies'
ALTER TABLE [dbo].[Movies]
ADD CONSTRAINT [PK_Movies]
    PRIMARY KEY CLUSTERED ([MovieId] ASC);
GO

-- Creating primary key on [ReportId] in table 'Reports'
ALTER TABLE [dbo].[Reports]
ADD CONSTRAINT [PK_Reports]
    PRIMARY KEY CLUSTERED ([ReportId] ASC);
GO

-- Creating primary key on [TvShowId] in table 'TvShows'
ALTER TABLE [dbo].[TvShows]
ADD CONSTRAINT [PK_TvShows]
    PRIMARY KEY CLUSTERED ([TvShowId] ASC);
GO

-- Creating primary key on [UserId] in table 'Users'
ALTER TABLE [dbo].[Users]
ADD CONSTRAINT [PK_Users]
    PRIMARY KEY CLUSTERED ([UserId] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------